<?php

/**
 * Laravel-admin - admin builder based on Laravel.
 * @author z-song <https://github.com/z-song>
 *
 * Bootstraper for Admin.
 *
 * Here you can remove builtin form field:
 * Encore\Admin\Form::forget(['map', 'editor']);
 *
 * Or extend custom form field:
 * Encore\Admin\Form::extend('php', PHPEditor::class);
 *
 * Or require js and css assets:
 * Admin::css('/packages/prettydocs/css/styles.css');
 * Admin::js('/packages/prettydocs/js/main.js');
 *
 */

Encore\Admin\Form::forget(['map', 'editor']);

/**
 * laravel-admin 扩展 飞书联合登录
 */
\Cann\Admin\OAuth\ServiceProvider::extend(\App\Admin\Extensions\OAuth\Feishu::class, 'Feishu', '飞书');

/**
 * laravel-admin Grid 初始化设置
 */
\Encore\Admin\Grid::init(function (\Encore\Admin\Grid $grid) {
    /**
     * 屏蔽导出按钮
     */
    $grid->disableExport();

    /**
     * 屏蔽批量删除按钮
     */
    $grid->tools(function (\Encore\Admin\Grid\Tools $tools) {
        $tools->batch(function ($batch) {
            $batch->disableDelete();
        });
    });

    /**
     * 屏蔽删除按钮
     */
    $grid->actions(function (\Encore\Admin\Grid\Displayers\Actions $actions) {
        $actions->disableDelete();
    });
});

/**
 * laravel-admin Form 统一设置
 */
\Encore\Admin\Form::init(function (\Encore\Admin\Form $form) {
    /**
     * 屏蔽编辑选中
     */
    $form->disableEditingCheck();

    /**
     * 屏蔽创建选中
     */
    $form->disableCreatingCheck();

    /**
     * 屏蔽显示选中
     */
    $form->disableViewCheck();

    /**
     * 屏蔽删除
     */
    $form->tools(function (\Encore\Admin\Form\Tools $tools) {
        $tools->disableDelete();
    });
});

/**
 * laravel-admin Show 统一设置
 */
\Encore\Admin\Show::init(function (\Encore\Admin\Show $show) {
    $show->panel()->tools(function (\Encore\Admin\Show\Tools $tools) {
        $tools->disableDelete();
    });
});


/**
 * laravel-admin 添加自定义js
 */
\Encore\Admin\Facades\Admin::script(
    <<<SCRIPT
$(function(){
    //设置box样式
    $("#app [class='box']").addClass('box-primary');
    $("#app [class='box grid-box']").addClass('box-primary');
    $("#app [class='box box-default']").attr('class','box box-primary');
    //$("#app .box").addClass('box-primary');
    //为表格添加样式
    $(".table").addClass('table-striped');
    //为固定表格在没有数据时添加默认的高度
    if($('.table-main tbody').children().size()<10){
        $('.table-main').css('min-height','60vh');
    }
});
SCRIPT
);
